from lib.models import Course
from lib.models import Grade
from google.appengine.ext import db
from lib import students_parser
from lib.BeautifulSoup import BeautifulSoup
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.runtime import DeadlineExceededError


def delete_all():
    query = db.GqlQuery("SELECT * FROM Grade")
    results = query.fetch(500)
    if results!=None:
        db.delete(results)
        return "ok"
    else:
        return "empty"

def reset():
    result = delete_all()
    return result




class MainPage(webapp.RequestHandler):
    def get(self):
        try:
            
            result = reset()
        except DeadlineExceededError:
            pass

        self.response.out.write(result)
application = webapp.WSGIApplication(
                                     [('/delete-grades', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
 
    main()
